/**
 *
 * @author Alex & Umit
 */
public class DLListQueue implements Queue {

    private DLList list;
    int size;

    public DLListQueue(){
        list = new DLList();
        size = 0;
    }

    public int size(){
        return size;
    }

    public boolean isEmpty(){
        return size == 0;
    }

    public Object front() throws EmptyQueueException{
        Object res = null;
        if(!isEmpty()){
            res = list.first().element();
        }
        else throw new EmptyQueueException();
        return res;

    }

    public void enqueue(Object o){
        list.addLast(o);
        size++;
    }

    public Object dequeue() throws EmptyQueueException{
        Object res = null;
        if(!isEmpty()){
            res = list.remove(list.first());
        }
        else throw new EmptyQueueException();
        return res;
    }

    @Override
    public String toString(){
        return "<DLListQueue[" + list.toString() + "]>";
    }
}